<template>
  <div style="background-color: var(--el-farms-win-bg-color);">
    <ai_view ref="aiRef" :appkyes="['goHome']"></ai_view>
  </div>
</template>
<script setup lang="ts">
import ai_view from './ai_view.vue';
import { onMounted, onUnmounted, ref } from 'vue';
import { useRoute } from 'vue-router';
import type { SendMsg } from '@/types/ai/SendMsg';
const route = useRoute();
const aiRef = ref();
const windowHeight = ref(window.innerHeight - 210);
const routWord = ref('');
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
const updateWindowSize = () => {
  windowHeight.value = window.innerHeight - 210;
};

// 在组件挂载时添加事件监听器
onMounted(() => {
  window.addEventListener('resize', updateWindowSize);
  if (route.query.word) {
    routWord.value = route.query.word as string;
    const msg = { msg: routWord.value } as SendMsg;
    aiRef.value.sendMsgByMsg(msg);
  }
});

// 在组件卸载时移除事件监听器
onUnmounted(() => {
  window.removeEventListener('resize', updateWindowSize);
});
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
</script>
<style scoped>
/* 样式可以根据需要添加 */
</style>
